<?php declare(strict_types=1);

use Hyperf\HttpServer\Router\Router;
use App\Bac\Controller\RBAC\AdminController;
use App\Bac\Controller\RBAC\MenuController;
use App\Bac\Controller\RBAC\RolesController;
use App\Bac\Controller\RBAC\PermissionController;

/**
 * 后台权限控制相关的路由声明
 */
Router::addGroup('/rbac', function () {
    // 账户接口
    Router::addGroup('/admin', function () {
        Router::get('', [AdminController::class, 'list']);
        Router::post('', [AdminController::class, 'create']);
        Router::put('/{id:\d+}', [AdminController::class, 'update']);
        Router::get('/{id:\d+}_{state:\d}', [AdminController::class, 'updateState']);
        Router::delete('/{id:\d+}', [AdminController::class, 'delete']);
    });
    // 权限管理
    Router::addGroup('/permission', function () {
        Router::get('', [PermissionController::class, 'index']);
        Router::post('', [PermissionController::class, 'create']);
        Router::put('', [PermissionController::class, 'edit']);
        Router::delete('', [PermissionController::class, 'del']);
    });
    //角色管理
    Router::addGroup('/role', function () {
        Router::get('', [RolesController::class, 'index']);
        Router::post('', [RolesController::class, 'create']);
        Router::put('', [RolesController::class, 'edit']);
        Router::delete('', [RolesController::class, 'del']);
    });
    //菜单管理
    Router::addGroup('/menu', function () {
        Router::get('', [MenuController::class, 'index']);
        Router::post('', [MenuController::class, 'create']);
        Router::put('', [MenuController::class, 'edit']);
        Router::delete('', [MenuController::class, 'del']);
    });
});